﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace XTDL_copy_tool
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string path = folderBrowserDialog1.SelectedPath;
                string[] folderNames = Directory.GetDirectories(path);

                textBox1.Text = ArrayToString(folderNames);
            }
        }

        public string ArrayToString (string[] array)
        {
            string names = "";
            for (int i = 0; i < array.Length; i++)
            {
                string temp = GetDirectoryNameFromPath(array[i]) + ", ";
                names += temp;
            }
            names = names.Remove(names.Length - 2);
            return names;
        }

        public string GetDirectoryNameFromPath (string directoryPath)
        {
            string directoryName = directoryPath.Substring(directoryPath.LastIndexOf('\\') +1);
            return directoryName;
        }

        private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
        {

        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            textBox1.SelectAll();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(textBox1.Text);
        }
    }
}
